﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ImageAcquisitionTAL.Properties;

namespace ImageAcquisitionTAL
{
    public static class ImageAcquisitionTechnologyFactory
    {
        public static IAcquisitionTechnology[] GetSupportedTechnologies()
        {
            List<IAcquisitionTechnology> techs = new List<IAcquisitionTechnology>();
            AddTechIfAvailable<NoTechnology>(techs);
            AddTechIfAvailable<WIA20Technology>(techs);
            AddTechIfAvailable<WIA10Technology>(techs);
            AddTechIfAvailable<ISISTechnology>(techs);
            AddTechIfAvailable<SANETechnology>(techs);
            AddTechIfAvailable<TWAINTechnology>(techs);
            if (techs.Count == 0) // none technology installed
                techs.Add(new NoTechnology());
            return techs.ToArray();
        }

        private static void AddTechIfAvailable<TechType>(List<IAcquisitionTechnology> techs) 
            where TechType : IAcquisitionTechnology, new()
        {
            IAcquisitionTechnology tech;
            tech = new TechType();
            if (tech.IsAvailable())
                techs.Add(tech);
        }
    }
}
